package com.multithreading.algorithm;

/**
 * @author zx
 * @version 1.0
 * @package_name: com.multithreading.algorithm
 * @date 2024/6/19 19:32
 */
public class LinearSearch {
    // 线性查找 Linear Search
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

        int index = 15;
        boolean flag = true;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == index) {
                System.out.println("index:" + i);
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println("not found");
        }
    }
}
